﻿/*!	@file	r_draw_texture2d_dx11.h
	@brief	2DテクスチャDX11
Copyright (c) 2010 Yuya Yamaguchi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _R_DRAW_TEXTURE2D_DX11_H_
#define _R_DRAW_TEXTURE2D_DX11_H_

#include "../r_draw_texture2d.h"
#if R_TARGET_UNIQUEIS(R_TARGET_UNIQUE_WINDX11)

#include <d3d11.h>

namespace r{
	namespace draw{
		namespace dx11{
			class CoreDX11;
		}
	}
}
namespace r{
	namespace draw{
		namespace dx11{
			//! 2次元テクスチャクラス
			/*!
			*/
			class Texture2DDX11 : public r::draw::Texture2D
			{
				RRTTI_REFLECTION_DECLARE
				friend class r::draw::dx11::CoreDX11;
			__r_serialize:
				//! RTTI用未使用
				Texture2DDX11() {}
			protected:
				//! コンストラクタ
				Texture2DDX11 ( ID3D11Texture2D* _texture, const Texture2DDesc& _desc, ID3D11ShaderResourceView* _resource );
				//! デストラクタ
				virtual ~Texture2DDX11();
			public:
				//! テクスチャを取得する
				/*!
				*/
				ID3D11Texture2D*			getTexture() const;
				//! リソースビューを取得する
				/*!
				*/
				ID3D11ShaderResourceView*	getResourceView() const;
				//! サブリソースを取得する
				/*!
				*/
				D3D11_MAPPED_SUBRESOURCE*	getSubResource() const;
			public:
				//! データを転送する
				/*!
				@param	data	[in]	テクスチャデータ

				dataの幅と高さ、フォーマットはTexture2DDescに沿った形式である必要がある。
				*/
				virtual	void			texImage( const void* data, r_ui32 mipLevel = 0 );
				//! 指定ピクセルに書き込む
				//! 指定ピクセルを読み取る
			protected:
			private:
				// コピー禁止
				Texture2DDX11 ( const Texture2DDX11& );
				Texture2DDX11& operator = ( const Texture2DDX11& );
			private:
				ID3D11Texture2D*			texture;
				ID3D11ShaderResourceView*	resource;
				D3D11_MAPPED_SUBRESOURCE	subresource;
				D3D11_MAPPED_SUBRESOURCE*	subresourcePointer;
			};
		}
	}
}

#endif // R_TARGET_UNIQUEIS(R_TARGET_UNIQUE_WINDX11)

#endif // _R_DRAW_TEXTURE2D_H_
